package org.hxyjs.dao.impl;



import org.hxyjs.dao.OrderFormItemDao;
import org.hxyjs.entity.Orderformitem;
import org.hxyjs.mapper.OrderformitemMapper;
import org.hxyjs.page.PageInfo;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;
import java.util.List;

@Repository("orderformitemDao")//一般实现类不会直接生成默认对象名 而是使用 接口的默认对象名
public class OrderformitemDaoImpl implements OrderFormItemDao {
    @Resource //autowired 会装配能够直接扫描到的对象  resource spring容器运行的时候才找到需要的对象  注入
    private OrderformitemMapper orderformitemMapper;

    public List<Orderformitem>  getAllOrderformitems() throws Exception{
        return orderformitemMapper.selectByExample(null);
    }

    @Override
    public List<Orderformitem> getOrderformitemByPage(PageInfo pageInfo) {
        return null;
    }

    @Override
    public Orderformitem getOrderformitemByUrno(String oino) throws Exception {
        return null;
    }
//    public List<Orderformitem> getOrderformitemByPage(PageInfo pageInfo) {
//        Map<String,Object> map = new HashMap<String,Object>();
//        map.put("currPage",pageInfo.getCurrPage());
//        map.put("pageSize",pageInfo.getPageSize());
//        int itemCount =(int) orderformitemMapper.countByExample(null);
//        pageInfo.setItemCount(itemCount);
//        return orderformitemMapper.getOrderformitemByPage(map);
//    }

//    @Override
//    public OrderformitemselectOrderformitemByUrno(String sno) throws Exception {
//        return orderformitemMapper.selectByPrimaryKey(sno);
//    }


    @Override
    public Integer deleteOrderformitemByUrno(String oino) {
        return orderformitemMapper.deleteByPrimaryKey(oino);
    }

    @Override
    public Integer updateOrderformitemByUrno(Orderformitem orderformitem) {
        return orderformitemMapper.updateByPrimaryKey(orderformitem);
    }

    @Override
    public Integer addOrderformitem(Orderformitem orderformitem) {
//        orderformitem.setUrno(initId());
        return orderformitemMapper.insertSelective(orderformitem);
    }

    @Override
    public Integer addOrderformitems(List<Orderformitem> orderformitems) throws Exception {
        return orderformitemMapper.inserBatch(orderformitems);
    }

//    public String initId() {
//        String maxUrno = orderformitemMapper.getMaxUrno();
//        return GenNumTools.initId("190001150012024042811", 4, maxUrno);
//    }
//    @Override
//    public OrderformitemgetOrderformitemByUrno(String oino) throws Exception{
//        return orderformitemMapper.selectByPrimaryKey(oino);
//    }

}